ICloneable
interface.When you add your own state in a subclass, and when you expect to be able to copy the data, you should override this method in your derived class when it has some fields that are object references. Your override method should first call base.Clone()
to get the newly copied object. The result should be the object you return, after performing any other deeper copying of referenced objects that you deem necessary, and after removing references that should not be shared (such as to cached data structures).
The standard implementation of this method is to do a shallow copy, by Object.MemberwiseClone()
, and reinitialize the FromKeys, ToKeys, and MemberKeys properties. You do not need to override this method if you have only added some fields/properties that are values or are references to intentionally shared objects.